ostree.git
9 years agoostree-prepare-root: Allow building statically with musl
William Manley [Tue, 30 Aug 2016 19:28:02 +0000 (20:28 +0100)]
ostree-prepare-root: Allow building statically with musl

If the `--with-static-compiler=musl-gcc` configure flag is given.

ostree-prepare-root can be used as init in a system without a populated
/lib.  To support this use case we need to link statically as we will be
unable to locate libc.so at run time if it's not installed in /lib.

We support building ostree-prepare-root with a different compiler to the
rest of ostree so we can use musl rather than glibc.  This reduces the size
of the executable significantly: from ~700K -> ~30K.  We have to use
`_SCRIPTS` here to get autotools to install this as an executable but
without generating rules to make it itself which we have specified
manually.

See https://lists.gnu.org/archive/html/help-gnu-utils/2007-01/msg00007.html
for advice on using autotools in this manner.

Closes: #477
Approved by: cgwalters

9 years agoswitchroot: Fix building with musl libc
William Manley [Tue, 26 Jul 2016 16:42:17 +0000 (17:42 +0100)]
switchroot: Fix building with musl libc

POSIX and GNU define conflicting versions of `strerror_r`.  The GNU
version returns the string but doesn't necessilary write into buf.
The POSIX version writes into buf and returns the length but doesn't
necessilary append a terminate the string with a NUL if it's too long
to fit in buf.

This commit fixes building ostree-prepare-root with musl libc.  The
stripped static build with musl on my machine is 30K vs. 724K with glibc
static and 11K with glibc shared.

Closes: #477
Approved by: cgwalters

9 years agocommit: Don't delete tmp/cache dir
Colin Walters [Mon, 29 Aug 2016 15:03:35 +0000 (11:03 -0400)]
commit: Don't delete tmp/cache dir

We hold a fd open on this, and it's basically now expected
to be immortal.  Confer that status.

This was showing up in flatpak crashers, because we'd get
an unexpected errno.

(I didn't test this fixes the crasher, but it's clearly right)

https://bugzilla.redhat.com/show_bug.cgi?id=1347293

Closes: #476
Approved by: alexlarsson

9 years agosysroot: Add a flag to suppress post-deploy cleanup
Colin Walters [Mon, 29 Aug 2016 02:22:59 +0000 (22:22 -0400)]
sysroot: Add a flag to suppress post-deploy cleanup

I noticed seeing the output of `prune` twice in rpm-ostree, and had
always wondered why.  When reading the rpm-ostree code to fix
something else, reasons, I noticed the reason - we were pruning once
here, and then once after rpm-ostree regenerates its "base" refs.

There's no reason to clean twice, so let's add a flag so rpm-ostree
can suppress doing it inside libostree.

Closes: #474
Approved by: giuseppe

9 years agosysroot: Drop unnecessary `dup()` invocation
Colin Walters [Sat, 27 Aug 2016 12:50:47 +0000 (08:50 -0400)]
sysroot: Drop unnecessary `dup()` invocation

It's close-on-exec, not close-on-fork.  I was clearly confused when
writing this; it works just fine to reference the fd in the child and
`fchdir()` before exec.  So drop the unnecessary duplication.

Just noticed this while reading the code for a random other reason.

Closes: #473
Approved by: giuseppe

9 years agou-boot: Merge ostree's and systems uEnv.txt
Gatis Paeglis [Tue, 23 Aug 2016 12:32:35 +0000 (14:32 +0200)]
u-boot: Merge ostree's and systems uEnv.txt

This is a proper fix for:
https://bugzilla.gnome.org/show_bug.cgi?id=755787

With this patch, an admin (system builder) can now:

1) Edit /usr/lib/ostree-boot/uEnv.txt
2) Deploy the new tree. OSTree will append system's uEnv.txt
   to the OSTree's managed uEnv.txt (loader/uEnv.txt).

It is common for u-boot systems to read in an extra env
from external /uEnv.txt. The same file OSTree uses to pass
in its env. With this patch /uEnv.txt now contains OSTree's
env + custom env added by system builders.

Closes: #466
Approved by: cgwalters

9 years agopull: use same name for parameter and documentation comment
Giuseppe Scrivano [Fri, 26 Aug 2016 15:35:17 +0000 (17:35 +0200)]
pull: use same name for parameter and documentation comment

Fixes this warning:

src/libostree/ostree-repo-pull.c:2162: Warning: OSTree: ostree_repo_pull_with_options: unknown parameter 'remote_name_or_baseurl' in documentation comment, should be 'remote_name'

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #472
Approved by: jlebon

9 years agolib: Add an API to list only "our" objects, fix prune to use it
Colin Walters [Thu, 25 Aug 2016 15:53:27 +0000 (11:53 -0400)]
lib: Add an API to list only "our" objects, fix prune to use it

When doing a prune, we should not try to delete objects in parent
repos, since it'll fail.  There is a bigger discussion about the
semantics of `parent=` to be had, but this will fix trying to use
`ostree prune --repo=/ostree/repo/extensions/rpmostree/pkgcache`.

Closes: https://github.com/ostreedev/ostree/issues/467
Closes: #471
Approved by: jlebon

9 years agorepo: Add prefixes to errors for querying size/deleting
Colin Walters [Thu, 25 Aug 2016 17:16:46 +0000 (13:16 -0400)]
repo: Add prefixes to errors for querying size/deleting

I hit these while causing errors in prune.  Let's add the specific
object we were looking for.

Closes: #471
Approved by: jlebon

9 years agopull: Make .commitpartial files world readable
Colin Walters [Thu, 25 Aug 2016 00:18:09 +0000 (20:18 -0400)]
pull: Make .commitpartial files world readable

In CentOS, these happened to appear in a repo that is served
via rsync, and having them not be world-readable caused mirroring
tools to fail.

They aren't secret, so don't make them so.

Closes: #468
Approved by: giuseppe

9 years agopull_with_options: fix stray return FALSE
Jonathan Lebon [Thu, 18 Aug 2016 14:37:11 +0000 (10:37 -0400)]
pull_with_options: fix stray return FALSE

Closes: #465
Approved by: cgwalters

9 years agopull_with_options: allow GPG verification override
Jonathan Lebon [Thu, 18 Aug 2016 14:35:31 +0000 (10:35 -0400)]
pull_with_options: allow GPG verification override

We used to only look at the "gpg-verify" and "gpg-verify-summary"
options when we're passed a local URL. Make these options also have an
effect in the configured remote case.

Closes: #465
Approved by: cgwalters

9 years agopull_with_options: fix remote parameter name & desc
Jonathan Lebon [Thu, 18 Aug 2016 14:34:50 +0000 (10:34 -0400)]
pull_with_options: fix remote parameter name & desc

Closes: #465
Approved by: cgwalters

9 years agorofiles-fuse: Rework to be based on nlink
Colin Walters [Tue, 16 Aug 2016 13:26:16 +0000 (09:26 -0400)]
rofiles-fuse: Rework to be based on nlink

Programs like `useradd` try to `open(/etc/passwd, O_RDWR)` to append,
which didn't work with rofiles-fuse.  Thinking about this, I realized
that there's a simpler algorithm for "can we write to this file" which
is "does it have a hardlink count <= 1"?

Switching to this both drops complexity (we no longer need to keep a
hash table of files we created), and also lets useradd work.

Closes: #462
Approved by: jlebon

9 years agotest-rofiles-fuse: Actually check out via hardlinks
Colin Walters [Tue, 16 Aug 2016 17:07:51 +0000 (13:07 -0400)]
test-rofiles-fuse: Actually check out via hardlinks

The test suite was actually doing something before, just
not quite what I intended.  Without `-U` for bare-user checkouts
we end up doing a copy.

Now, a future commit will change how rofiles work, which would cause
the test suite to permit inplace mutation for non-hardlinked files.
So let's ensure they *are* hardlinked.

Closes: #462
Approved by: jlebon

9 years agofixup! fix typo in docs/manual/atomic-upgrades.md
Colin Walters [Fri, 12 Aug 2016 21:15:59 +0000 (17:15 -0400)]
fixup! fix typo in docs/manual/atomic-upgrades.md

Closes: #461
Approved by: giuseppe

9 years agoprune: Elaborate on what formats are accepted by dates
Colin Walters [Fri, 12 Aug 2016 21:10:54 +0000 (17:10 -0400)]
prune: Elaborate on what formats are accepted by dates

Inquiring minds want to know.

Closes: #461
Approved by: giuseppe

9 years agofix typo in docs/manual/atomic-upgrades.md
Adam Miller [Fri, 12 Aug 2016 19:37:18 +0000 (14:37 -0500)]
fix typo in docs/manual/atomic-upgrades.md

Signed-off-by: Adam Miller <maxamillion@fedoraproject.org>
Closes: #460
Approved by: cgwalters

9 years agorepo: Really ignore progress changed user data
Dan Nicholson [Thu, 11 Aug 2016 19:39:19 +0000 (12:39 -0700)]
repo: Really ignore progress changed user data

The documentation says this is ignored, implying that you should pass
NULL to it. However, the function immediately returns in this case even
though the argument isn't used anywhere.

Closes: #458
Approved by: cgwalters

9 years agomanual/repo.md: reword bits about the summary file
Jonathan Lebon [Wed, 10 Aug 2016 19:11:14 +0000 (15:11 -0400)]
manual/repo.md: reword bits about the summary file

Closes: #459
Approved by: cgwalters

9 years agoostree_bootdir: properly preprend $(prefix)
Jonathan Lebon [Thu, 11 Aug 2016 15:46:44 +0000 (11:46 -0400)]
ostree_bootdir: properly preprend $(prefix)

Closes: #457
Approved by: cgwalters

9 years agoostree_bootdir: prepend $(prefix) to path
Jonathan Lebon [Thu, 11 Aug 2016 14:29:56 +0000 (10:29 -0400)]
ostree_bootdir: prepend $(prefix) to path

Otherwise we break local installs.

Closes: #456
Approved by: cgwalters

9 years agoMove ostree-* executables to /usr/lib/ostree
Gatis Paeglis [Tue, 9 Aug 2016 13:23:04 +0000 (15:23 +0200)]
Move ostree-* executables to /usr/lib/ostree

Why not to use libexecdir?

Because this directory does not exist on some distros or paths
between distros varies. There are several reasons why a well
known path is prefered, for example when generating a kernel
command line:

init=${ostree}/usr/lib/ostree-boot/ostree-prepare-root

In addition this saves us some typing in a console when wanting
to access the "ostree" cmd line.

Closes: #449
Approved by: cgwalters

9 years agotests: Test that local pulls do not use deltas
Dan Nicholson [Tue, 9 Aug 2016 22:41:36 +0000 (15:41 -0700)]
tests: Test that local pulls do not use deltas

Pulls from local repos now default to disabling static deltas so that
objects are copied. To check this is the case, see if the object files
are hardlinked after pulling.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agopull: Disable static deltas by default for local pulls
Dan Nicholson [Fri, 5 Aug 2016 13:52:55 +0000 (06:52 -0700)]
pull: Disable static deltas by default for local pulls

For local pulls there's no benefit pulling the static delta over the
individual object files since there's no HTTP overhead. Furthermore,
processing deltas always generates the objects whereas a standard pull
ensures that the exact object files are copied. Using deltas also
prevents hardlinking the objects if the repos exist on the same
filesystem.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agotests: Ensure deltas for pulling when needed
Dan Nicholson [Tue, 9 Aug 2016 22:39:41 +0000 (15:39 -0700)]
tests: Ensure deltas for pulling when needed

When testing pulling of deltas, use the new --require-static-deltas
option to pull-local to ensure that deltas are actually used. To support
the require-static-deltas mode, the summary in the remote repo must be
generated.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agopull-local: Support requiring static deltas
Dan Nicholson [Tue, 9 Aug 2016 16:41:48 +0000 (09:41 -0700)]
pull-local: Support requiring static deltas

Add the --require-static-deltas option like pull to ensure static deltas
are processed for local pulls.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agodeltas: Use F_DUPFD_CLOEXEC properly
Dan Nicholson [Tue, 9 Aug 2016 18:46:30 +0000 (11:46 -0700)]
deltas: Use F_DUPFD_CLOEXEC properly

You need to supply an argument to F_DUPFD_CLOEXEC or fcntl will return
EINVAL. Use 3 as the minimum fd number as is standard.

Closes: #454
Closes: #448
Approved by: cgwalters

9 years agodeltas: Handle cleanup of fd array properly
Dan Nicholson [Tue, 9 Aug 2016 18:45:25 +0000 (11:45 -0700)]
deltas: Handle cleanup of fd array properly

If there's an early error, part_temp_fds will be NULL and dereferencing
the len member will segfault.

Closes: #454
Closes: #448
Approved by: cgwalters

9 years agolibostree.sym: Add 2016.9 section
Colin Walters [Tue, 9 Aug 2016 19:36:37 +0000 (15:36 -0400)]
libostree.sym: Add 2016.9 section

We should remember to do this in the commit updating configure.ac.

Closes: #453
Approved by: jlebon

9 years agoRelease 2016.8
Colin Walters [Tue, 9 Aug 2016 17:58:02 +0000 (13:58 -0400)]
Release 2016.8

It's time for a new release, there's enough queued and it's
been ~a month.

Closes: #452
Approved by: jlebon

9 years agotests: Port sysroot.js away from libgsystem
Colin Walters [Tue, 9 Aug 2016 17:52:43 +0000 (13:52 -0400)]
tests: Port sysroot.js away from libgsystem

My case-sensitive `git grep` didn't find this one originally,
but the Travis+Debian setup was configured to run it.

Closes: #451
Approved by: jlebon

9 years agotravis: Disable email notifications
Colin Walters [Tue, 9 Aug 2016 16:51:30 +0000 (12:51 -0400)]
travis: Disable email notifications

I'm getting spammed.  We'll see the results in the status.

Closes: #450
Approved by: jlebon

9 years agoFinal excision of libgsystem dependency
Colin Walters [Thu, 23 Jun 2016 00:12:31 +0000 (20:12 -0400)]
Final excision of libgsystem dependency

Lots and lots of preparation led to this moment - when nothing
apparent changes for users!  Woo!

But seriously, having the extra dependency is a minor annoyance, and
in the big picture I think the libgsystem idea was wrong - we need to
land things in GLib, and use git submodules for API-unstable or
Linux-specific sharing.  For a lot of OSTree, the libgsystem `GFile*`
orientation was also wrong, we really want fd-relative.

Closes: #444
Approved by: jlebon

9 years agoprune: Retain the tip of each ref even with date pruning
Colin Walters [Mon, 8 Aug 2016 19:41:09 +0000 (15:41 -0400)]
prune: Retain the tip of each ref even with date pruning

I hit an error with [CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel)
where we were doing time-based pruning.  `ostree summary -u` started failing,
and it took me a bit to realize it was because we were pruning
even the tip of old branches, which I was not at all expecting,
and I don't think users will too.

Perhaps in the future we could add some sort of --prune-ref-tips or
something if people wanted it, but I doubt it.

Closes: #445
Approved by: jlebon

9 years agobuild: Update .gitignore
Colin Walters [Tue, 9 Aug 2016 00:19:54 +0000 (20:19 -0400)]
build: Update .gitignore

The patch to add more symlink bits also needed CLEANFILES updates.

Closes: #446
Approved by: jlebon

9 years agodeploy: Use internal recursive copy rather than libgsystem
Colin Walters [Thu, 4 Aug 2016 13:37:26 +0000 (09:37 -0400)]
deploy: Use internal recursive copy rather than libgsystem

Since we already had a "recursive copy" implementation here, let's
reuse it rather than the libgsystem `gs_shutil_cp_a()`.  Part of the
libglnx porting.

Closes: #428
Approved by: jlebon

9 years agodeploy: Port file copying code to GLnxDirFdIterator
Colin Walters [Thu, 4 Aug 2016 01:24:09 +0000 (21:24 -0400)]
deploy: Port file copying code to GLnxDirFdIterator

It handles ownership of the `DIR*` for us more cleanly, and
is just a better API.

This is in preparation for further changes to this code to do SELinux
labeling while copying.

Closes: #428
Approved by: jlebon

9 years agorepo: Fix an uninitialized variable
Colin Walters [Mon, 8 Aug 2016 10:34:50 +0000 (06:34 -0400)]
repo: Fix an uninitialized variable

Closes: #431
Approved by: giuseppe

9 years agobuild: Make -Werror=int-conversion fatal
Colin Walters [Thu, 4 Aug 2016 20:58:07 +0000 (16:58 -0400)]
build: Make -Werror=int-conversion fatal

This should hopefully avoid me accidentally passing NULL for an `int`
file descriptor in the future.

Closes: #431
Approved by: giuseppe

9 years agobuild: Import attributes.m4, detect CFLAGS at build time
Colin Walters [Thu, 4 Aug 2016 20:47:46 +0000 (16:47 -0400)]
build: Import attributes.m4, detect CFLAGS at build time

I want to add `-Werror=int-conversion`, but it's only available in
newer GCC versions.  So let's start autodetecting available compiler
flags.

Closes: #431
Approved by: giuseppe

9 years agorepo: Drop more internally unused GFile members
Colin Walters [Fri, 5 Aug 2016 11:08:14 +0000 (07:08 -0400)]
repo: Drop more internally unused GFile members

I forgot to actually remove `config_file` in the previous
commit, the txn lock hasn't been used in a long time, and
for the uncompressed cache, everything uses the fd already.

Closes: #433
Approved by: giuseppe

9 years agotravis: run the test suite on various distributions
Simon McVittie [Fri, 5 Aug 2016 21:12:55 +0000 (22:12 +0100)]
travis: run the test suite on various distributions

.travis.yml is obviously still Travis-specific, but tests/ci-* are
designed to be shareable with other CI environments if there is interest
in doing so.

At the moment I'm only testing on Debian and Ubuntu. In principle we
could try a non-Debian-derived Docker container such as Fedora or CentOS
inside travis-ci's Ubuntu environment, similar to what I'm doing
for Debian, but I don't know the correct setup commands to use there.

Closes: #438
Approved by: cgwalters

9 years ago.travis.yml: Delete, we aren't using it right now
Colin Walters [Fri, 5 Aug 2016 20:30:13 +0000 (16:30 -0400)]
.travis.yml: Delete, we aren't using it right now

@smcv will re-add a new version.

Closes: #439
Approved by: smcv

9 years agoSkip tests that use whiteouts under Docker/aufs
Simon McVittie [Fri, 5 Aug 2016 19:41:05 +0000 (20:41 +0100)]
Skip tests that use whiteouts under Docker/aufs

ostree's naming convention for whiteouts is similar to what is
done in aufs, which means we can't compose the trees to test this
feature under Docker with the aufs storage driver, as used on
travis-ci.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #437
Approved by: cgwalters

9 years agoUpdate libglnx: Add missing files to libglnx distribution
Simon McVittie [Fri, 5 Aug 2016 13:38:34 +0000 (14:38 +0100)]
Update libglnx: Add missing files to libglnx distribution

This fixes distcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #436
Approved by: cgwalters

9 years agorepo: Drop internal GFile config_file
Colin Walters [Fri, 5 Aug 2016 01:49:05 +0000 (21:49 -0400)]
repo: Drop internal GFile config_file

The remote parsing code still uses GFiles but this is a start.

Closes: #432
Approved by: giuseppe

9 years agolib: Drop GFiles for self->{objects_dir,state_dir}
Colin Walters [Fri, 5 Aug 2016 01:31:39 +0000 (21:31 -0400)]
lib: Drop GFiles for self->{objects_dir,state_dir}

Everything that used to reference these is now fd-relative.

Closes: #432
Approved by: giuseppe

9 years agorepo: Port metadata writing code to fd-relative
Colin Walters [Fri, 5 Aug 2016 01:30:56 +0000 (21:30 -0400)]
repo: Port metadata writing code to fd-relative

It was the last thing referencing `self->objects_dir`.

Closes: #432
Approved by: giuseppe

9 years agolib: Fix a compiler warning introduced from earlier patch
Colin Walters [Thu, 4 Aug 2016 20:35:49 +0000 (16:35 -0400)]
lib: Fix a compiler warning introduced from earlier patch

I think we'd end up closing stdin...yuck.  Need to investigate
having this be fatal, but CentOS 7 `gcc-4.8.5` doesn't understand
`-Werror=int-conversion`.

Closes: #430
Approved by: giuseppe

9 years agolib: Use libglnx file replace API more consistently
Colin Walters [Thu, 4 Aug 2016 17:29:13 +0000 (13:29 -0400)]
lib: Use libglnx file replace API more consistently

We have a better API now, drop use of the internal helper, which also
depended on libgsystem.

This required bumping libglnx to pull in a fix.

Closes: #429
Approved by: giuseppe

9 years agoUpdate libglnx for O_TMPFILE build time option
Colin Walters [Wed, 3 Aug 2016 17:16:30 +0000 (13:16 -0400)]
Update libglnx for O_TMPFILE build time option

See: https://github.com/ostreedev/ostree/issues/421

Closes: #426
Approved by: gatispaeglis

9 years agolib: Add padding booleans to OstreeRepoCheckoutAtOptions
Colin Walters [Thu, 4 Aug 2016 11:22:41 +0000 (07:22 -0400)]
lib: Add padding booleans to OstreeRepoCheckoutAtOptions

Since this is a new API, and adding booleans is the most likely thing
we'll do, let's stick some explicit padding for them in here now.

We could use the `unused_ints[]` but it'd be out of order, and this
will more clearly remind people about the padding.  The efficiency hit
versus bitfields is annoying, but oh well, not a real world problem.

Closes: #427
Approved by: giuseppe

9 years agorepo: Flip the fsync default to off for new checkout API
Colin Walters [Wed, 3 Aug 2016 14:55:35 +0000 (10:55 -0400)]
repo: Flip the fsync default to off for new checkout API

Since we're adding a new API, we have the opportunity to fix
the defaults.  We expect clients to do a `syncfs()` or equivalent
on their own now, since it's way more efficient.

Flip the checkout fsync default to off.

Closes: #425
Approved by: giuseppe

9 years agodeltas: Port compilation to libglnx/fd-relative
Colin Walters [Tue, 2 Aug 2016 18:49:42 +0000 (14:49 -0400)]
deltas: Port compilation to libglnx/fd-relative

This was the last use of libgsystem tmpfile APIs.  The change here is
a bit uglier than it needs to be because we support creating the delta
in place as well as in the repo, so we needed to abstract over
locations.

Closes: #424
Approved by: giuseppe

9 years agogrub2: Port away from gs_file_sync_data()
Colin Walters [Mon, 1 Aug 2016 01:31:45 +0000 (21:31 -0400)]
grub2: Port away from gs_file_sync_data()

Inlining this is uglier, but this code kind of sucks anyways =( We're
going to need to do some fd-relative porting in here at some point.

Closes: #424
Approved by: giuseppe

9 years agolib: Port away from gs_file_rename()
Colin Walters [Mon, 1 Aug 2016 01:33:15 +0000 (21:33 -0400)]
lib: Port away from gs_file_rename()

In one case, we already had relative fds and hence this was
nicer.  Unfortunately the other areas got uglier.  More fd-relative
porting to do later.

Closes: #424
Approved by: giuseppe

9 years agoostree-prepare-root: Add test that overlayfs over /usr works.
William Manley [Sun, 31 Jul 2016 21:19:13 +0000 (22:19 +0100)]
ostree-prepare-root: Add test that overlayfs over /usr works.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Fix typo in error message
William Manley [Tue, 26 Jul 2016 17:05:25 +0000 (18:05 +0100)]
ostree-prepare-root: Fix typo in error message

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Make error message capitalisation consistent
William Manley [Tue, 26 Jul 2016 16:53:53 +0000 (17:53 +0100)]
ostree-prepare-root: Make error message capitalisation consistent

There seemed to be more lower case first letters so I've standardised
on that.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Use pivot_root if real sysroot is already mounted at /
William Manley [Tue, 19 Jul 2016 18:48:23 +0000 (19:48 +0100)]
ostree-prepare-root: Use pivot_root if real sysroot is already mounted at /

This allows ostree-prepare-root outside of the initramfs context where the
real rootfs is already mounted at /.  We can't use `mount --move` in this
case because we would be trying to move / into a subdirectory of itself.

Closes: #403
Approved by: cgwalters

9 years agoRefactor ostree-prepare-root: Perform chdir to deploy directory earlier
William Manley [Mon, 18 Jul 2016 17:09:10 +0000 (18:09 +0100)]
Refactor ostree-prepare-root: Perform chdir to deploy directory earlier

...for simplicity.  This way we don't need to keep concatenating
deploy_path to everything.  We can just refer relative to the current
working directory.

We need to do this after bind-mounting it over itself otherwise our cwd
is still on the non-bind-mounted filesystem below.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Refactor: Create /sysroot.tmp much later
William Manley [Mon, 18 Jul 2016 17:02:12 +0000 (18:02 +0100)]
ostree-prepare-root: Refactor: Create /sysroot.tmp much later

Typically we have our ready made-up up root at
`/sysroot/ostree/deploy/.../` (`deploy_path`) and the real rootfs at
`/sysroot` (`root_mountpoint`).  We want to end up with our made-up root
at `/sysroot/` and the real rootfs under `/sysroot/sysroot` as systemd
will be responsible for moving `/sysroot` to `/`.

We need to do this in 3 moves to avoid trying to move `/sysroot` under
itself:

1. `/sysroot/ostree/deploy/...` -> `/sysroot.tmp`
2. `/sysroot` -> `/sysroot.tmp/sysroot`
3. `/sysroot.tmp` -> `/sysroot`

This is a refactoring to group all these operations together so I can
implement an alternative in terms of `pivot_root`.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Cope with /proc not being mounted
William Manley [Mon, 18 Jul 2016 16:44:19 +0000 (17:44 +0100)]
ostree-prepare-root: Cope with /proc not being mounted

When trying to read kernel command-line.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root as init: exec init from deployment if run as PID1
William Manley [Mon, 18 Jul 2016 16:03:11 +0000 (17:03 +0100)]
ostree-prepare-root as init: exec init from deployment if run as PID1

This supports running ostree on embedded platforms without an initrd.
Specificially I'm trying to do bringup on an NVidia Tegra based Jetson TK1
dev board.

Closes: #403
Approved by: cgwalters

9 years agoostree-prepare-root: Refactor code to resolve deploy_path
William Manley [Mon, 18 Jul 2016 13:42:40 +0000 (14:42 +0100)]
ostree-prepare-root: Refactor code to resolve deploy_path

I'll reuse this for a new ostree-init.

Closes: #403
Approved by: cgwalters

9 years agotests: Add basic tests for ostree-prepare-root
William Manley [Wed, 27 Jul 2016 15:40:05 +0000 (16:40 +0100)]
tests: Add basic tests for ostree-prepare-root

These tests use unshare and mount to prepare a fake initrd/early boot
directory structure so we can then test ostree-prepare-root.

Things that are tested:

* Running in an initrd environment
* Running without initrd
* /var and /sysroot being mounted correctly
* /usr being mounted read-only

Things not tested (yet):

* Running as init - this could be accomplished by unsharing the pid
  namespace too.
* mounting/unmounting `/proc` if `/proc/cmdline` isn't available
* Persistent overlayfs for `/usr`
* Probably other things

The tests are basic but can be extended in the future as we do more work
on `ostree-prepare-root`.

These tests must be run as root as they require the ability to `mount`
and to `unshare` the mount namespace. Perhaps in the future we can use
user namespaces for this test once they are more widely available.

Closes: #403
Approved by: cgwalters

9 years agorepo: Port to g_autoptr() rather than old style cleanup macros
Colin Walters [Mon, 1 Aug 2016 00:50:07 +0000 (20:50 -0400)]
repo: Port to g_autoptr() rather than old style cleanup macros

This notably kills a few libgsystem uses here.

Closes: #423
Approved by: giuseppe

9 years agorepo: Port sign_data() to libglnx tmpfile APIs
Colin Walters [Mon, 1 Aug 2016 00:58:32 +0000 (20:58 -0400)]
repo: Port sign_data() to libglnx tmpfile APIs

Part of dropping libgsystem.

Closes: #423
Approved by: giuseppe

9 years agodeploy: Replace a use of gs_file_enumerator with compat wrapper
Colin Walters [Mon, 1 Aug 2016 01:03:16 +0000 (21:03 -0400)]
deploy: Replace a use of gs_file_enumerator with compat wrapper

More libglnx/glib porting.

Closes: #423
Approved by: giuseppe

9 years agorepo: Make ostree_repo_create() nonfatal on existing repos
Colin Walters [Mon, 1 Aug 2016 14:43:49 +0000 (10:43 -0400)]
repo: Make ostree_repo_create() nonfatal on existing repos

In general we want to support "idempotentcy" or "state
synchronization" across interruption.  If a repo is only partially
created due to a crash or whatever, it's hard for a user to know that.
Let's just make `ostree_repo_create()` idempotent. Since all we're
doing is a set of `mkdirat()` invocations, it's quite simple.

This also involved porting to fd-relative, which IMO makes the
code a lot clearer.

Closes: #422
Approved by: 14rcole

9 years agotests: Add test for delta with empty parts
Dan Nicholson [Sat, 30 Jul 2016 16:00:04 +0000 (09:00 -0700)]
tests: Add test for delta with empty parts

Closes: #420
Approved by: cgwalters

9 years agodeltas: Allow processing of empty delta parts
Dan Nicholson [Sat, 30 Jul 2016 15:14:17 +0000 (10:14 -0500)]
deltas: Allow processing of empty delta parts

If a static delta is generated between 2 commits with the same content,
then the delta will contain 1 part with no checksums. While useless,
this is a valid delta that shouldn't raise an assertion. If the delta
part has no checksums, then there are no objects to recreate and the
processing can be skipped.

Closes: #420
Approved by: cgwalters

9 years agolibostree, ostree: fix usage of ostree_repo_checkout_tree_at
Giuseppe Scrivano [Wed, 27 Jul 2016 09:34:22 +0000 (11:34 +0200)]
libostree, ostree: fix usage of ostree_repo_checkout_tree_at

it was deprecated, use ostree_repo_checkout_at.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #417
Approved by: cgwalters

9 years agolibostree: skip introspection for two functions
Giuseppe Scrivano [Fri, 29 Jul 2016 14:03:11 +0000 (16:03 +0200)]
libostree: skip introspection for two functions

These two functions are not safe for gobject introspection, so annotate
them to be skipped:

1) ostree_repo_import_archive_to_mtree
2) ostree_repo_export_tree_to_archive

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #417
Approved by: cgwalters

9 years agolibostree: mark ostree_repo_checkout_tree_at as deprecated
Giuseppe Scrivano [Wed, 27 Jul 2016 09:11:13 +0000 (11:11 +0200)]
libostree: mark ostree_repo_checkout_tree_at as deprecated

and move its definition to a separate file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #417
Approved by: cgwalters

9 years agolibostree: new function ostree_repo_checkout_at
Giuseppe Scrivano [Wed, 27 Jul 2016 08:38:36 +0000 (10:38 +0200)]
libostree: new function ostree_repo_checkout_at

Provide a gobject introspection safe version for
`ostree_repo_checkout_tree_at'.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #417
Approved by: cgwalters

9 years agolibglnx porting: Migrate to new tempfile code
Colin Walters [Mon, 27 Jun 2016 01:59:12 +0000 (21:59 -0400)]
libglnx porting: Migrate to new tempfile code

In general this is even cleaner now, though it was better after I
extracted a helper function for the "write tempfile with contents"
bits that were shared between metadata and regular file codepaths.

Closes: #369
Approved by: jlebon

9 years agostatic-delta: remove unused struct
Jonathan Lebon [Fri, 29 Jul 2016 16:31:42 +0000 (12:31 -0400)]
static-delta: remove unused struct

Closes: #418
Approved by: cgwalters

9 years agostatic-delta: fix command contexts
Jonathan Lebon [Fri, 29 Jul 2016 14:57:44 +0000 (10:57 -0400)]
static-delta: fix command contexts

Closes: #418
Approved by: cgwalters

9 years agodeltas: Handle untrusted checksums faster and more robustly
Colin Walters [Mon, 11 Jul 2016 13:29:18 +0000 (09:29 -0400)]
deltas: Handle untrusted checksums faster and more robustly

When reworking the ostree core [to use O_TMPFILE](https://github.com/ostreedev/ostree/pull/369),
I hit an issue in the way the untrusted delta codepath ends up trying
to re-open the file to checksum it.  That's not possible with
`O_TMPFILE` since the fd (which we opened `O_WRONLY`) is the only
accessible reference to the content.

Fix this by changing the delta processing code to update a checksum as
we're doing writes, which is also faster, and ends up simplifying the
code as well.

What would be an even larger simplification here is if we e.g. used a
separate thread calling `write_object()` or something like that; the
main issue I see there is somehow bridging the fact that function
wants a `GInputStream*` but the delta code is generating stream of
writes.

Closes: #392
Approved by: jlebon

9 years agotests/delta-crosscheck: Add missing --from
Colin Walters [Fri, 29 Jul 2016 01:06:38 +0000 (21:06 -0400)]
tests/delta-crosscheck: Add missing --from

Otherwise we generate a static delta from the *previous* and get
confused.  To make doubly sure, add `--require-static-deltas` to pull.

Closes: #416
Approved by: jlebon

9 years agolib: Fix compiler warning from previous patch
Colin Walters [Thu, 28 Jul 2016 13:57:48 +0000 (09:57 -0400)]
lib: Fix compiler warning from previous patch

I had this in a `fixup!` I thought.

Closes: #414
Approved by: giuseppe

9 years agolib: Fix leak in bootconfig parser
Colin Walters [Sun, 24 Jul 2016 19:45:02 +0000 (15:45 -0400)]
lib: Fix leak in bootconfig parser

Pretty simple.

Closes: #410
Approved by: giuseppe

9 years agodeploy: Fix leaks in parsing /etc/os-release
Colin Walters [Sun, 24 Jul 2016 19:40:49 +0000 (15:40 -0400)]
deploy: Fix leaks in parsing /etc/os-release

This one is a bit subtle; we're generating a hash that contains
pointers to the strings we parsed, so we need to carefully track
ownership.

Closes: #410
Approved by: giuseppe

9 years agosysroot: Fix a leak in deployment dirpath API
Colin Walters [Sun, 24 Jul 2016 19:40:22 +0000 (15:40 -0400)]
sysroot: Fix a leak in deployment dirpath API

This one is pretty obvious in retrospect.

Closes: #410
Approved by: giuseppe

9 years agoglib.supp: Suppress g_task -> thread leaks
Colin Walters [Sun, 24 Jul 2016 19:26:11 +0000 (15:26 -0400)]
glib.supp: Suppress g_task -> thread leaks

There are variants of this, but right now because `GTask` has its
own pool which isn't necessarily cleaned up on exit, we need
to suppress all of this.

Closes: #410
Approved by: giuseppe

9 years agofetcher: Explicitly join thread if it's not self
Colin Walters [Sun, 24 Jul 2016 19:11:17 +0000 (15:11 -0400)]
fetcher: Explicitly join thread if it's not self

This fixes a valgrind leak; see [this StackOverflow thread](http://stackoverflow.com/questions/17642433/why-pthread-causes-a-memory-leak).

Closes: #410
Approved by: giuseppe

9 years agoglib.supp: Suppress worker context -> thread bits
Colin Walters [Sun, 24 Jul 2016 19:10:55 +0000 (15:10 -0400)]
glib.supp: Suppress worker context -> thread bits

The worker context isn't cleaned up now.

Closes: #410
Approved by: giuseppe

9 years agopull-local: Explicitly unref variant rather than relying on floating
Colin Walters [Sun, 24 Jul 2016 19:00:02 +0000 (15:00 -0400)]
pull-local: Explicitly unref variant rather than relying on floating

This shows up as a leak in valgrind; the callee isn't sinking.  In
general through the power of cleanup attributes we can do explicit
cleanup rather than relying on floating refs.

Closes: #410
Approved by: giuseppe

9 years agoglib.supp: Suppress some dynamic type registrations too
Colin Walters [Sun, 24 Jul 2016 18:59:33 +0000 (14:59 -0400)]
glib.supp: Suppress some dynamic type registrations too

These mirror the static ones, and we need the dynamic versions for
glib-networking -> gnutls stuff.

Closes: #410
Approved by: giuseppe

9 years agotrivial-httpd: Fix leak of option context
Colin Walters [Sun, 24 Jul 2016 18:54:07 +0000 (14:54 -0400)]
trivial-httpd: Fix leak of option context

Right now our valgrind runs also end up valgrinding the
`trivial-httpd` code, so while it doesn't matter, let's fix this leak
anyways.  We need to avoid calling `_exit()` since that won't run the
cleanup functions.

Closes: #410
Approved by: giuseppe

9 years agopull: Don't execute static deltas when mirroring
Colin Walters [Fri, 22 Jul 2016 20:58:26 +0000 (16:58 -0400)]
pull: Don't execute static deltas when mirroring

We don't presently support this, since the static delta code assumes
it can just `mmap()` file objects.  We could at some point implement
this, but for now just skip executing deltas when doing
`archive -> archive` mirroring.

I noticed this when trying to mirror a repo in Jenkins in
[CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel).

Closes: #408
Approved by: giuseppe

9 years agorepo: Fix leak with ostree_repo_commit_traverse_iter_init_commit()
Colin Walters [Fri, 8 Jul 2016 15:26:45 +0000 (11:26 -0400)]
repo: Fix leak with ostree_repo_commit_traverse_iter_init_commit()

I noticed this using `OT_TEST_VALGRIND=1` on `test-basic.sh`.

Closes: #385
Approved by: jlebon

9 years agolibglnx: bump to latest
Jonathan Lebon [Fri, 22 Jul 2016 13:34:32 +0000 (09:34 -0400)]
libglnx: bump to latest

OSTree can sometimes print very long lines which lead to many empty
spaces getting printed if the output overflowed the line due to a bug in
libglnx.

Reported-by: Gatis Paeglis <gatis.paeglis@qt.io>
Closes: #406
Approved by: cgwalters

9 years agodocs/formats: Elaborate a bit on delta from NULL usage
Colin Walters [Tue, 19 Jul 2016 14:24:18 +0000 (10:24 -0400)]
docs/formats: Elaborate a bit on delta from NULL usage

See discussion on ostree-list.

Closes: #402
Approved by: gatispaeglis

9 years agobuild: Make symlink depend on source
Colin Walters [Fri, 15 Jul 2016 15:17:43 +0000 (11:17 -0400)]
build: Make symlink depend on source

Closes: https://github.com/ostreedev/ostree/issues/389
Closes: #400
Approved by: smcv

9 years agocore: Add allocating b64 checksum functions
Dan Nicholson [Thu, 14 Jul 2016 16:09:12 +0000 (09:09 -0700)]
core: Add allocating b64 checksum functions

The checksum_b64_inplace variants can't be used in bindings. Provide
versions that allocate and return the output rather than working on a
passed in buffer. These can then be used in GI bindings to get the
ostree modified base64 encodings.

Closes: #398
Approved by: cgwalters

9 years agolib: Fix version script node ordering
Dan Nicholson [Thu, 14 Jul 2016 19:45:39 +0000 (12:45 -0700)]
lib: Fix version script node ordering

The order of the VERSION nodes is such that the new node name goes first
and the one it depends on goes after the commands. See
https://sourceware.org/binutils/docs/ld/VERSION.html.

Closes: #398
Approved by: cgwalters

9 years agoREADME: Fix broken link
Matthew Leeds [Thu, 14 Jul 2016 20:10:55 +0000 (16:10 -0400)]
README: Fix broken link
Closes: #397
Approved by: cgwalters